# 传递列表

# 1. python中，将列表传递到函数之后，对于列表的改变是永久性的
print('----- 打印name -----')
def greet_users(names: list):
    # 向列表中的每个用户发出简单的问候
    for name in names:
        print("Hello ,"+ name)

users_name = ["Jiang","Jim","John","Mike"]
greet_users(users_name)
# 2. 在函数中对列表进行修改
print('----- 打印models -------')
def print_models(unprinted_design:list, completed_models:list):
    while unprinted_design:
        current_design = unprinted_design.pop()
        print("Printing model: "+current_design)
        completed_models.append(current_design)
def show_completed_models(completed_models:list):
    print('The following models have been printed: ')
    for model in completed_models:
        print(model)

unprinted_design = ['dodecahedron','robot pendant','iphone case']
completed_models = []
print_models(unprinted_design=unprinted_design, completed_models=completed_models)
show_completed_models(completed_models=completed_models)
print('----- 函数改变列表元素 ------')
print(unprinted_design)
print(completed_models)
# 3. 如果不想改变列表元素，则在传入列表时传入整个列表的切片unprinted_design[:],此时传入的是列表的副本